<template>
  <div>
    <div class="todo-footer" v-show="allTotal">
    <label>
      <input
        type="checkbox"
        v-model="updateAll"
      />
    </label>
    <span>已完成{{ allTotalChecked }}</span> <span>/ 全部{{ allTotal }} </span>
    <button class="btn btn-danger" @click="delAllChecked" v-show="allTotalChecked">清除已完成任务</button>
  </div>
  <h1 v-show="!allTotal">恭喜你没有任何任务要完成！</h1>
  </div>
</template>

<script>
export default {
  name: "Footer",
  props: {
    todos: Array,
    isAllChecked: Function,
    allTotalChecked: Number,
    allTotal: Number,
    delAllChecked:Function
  },

  computed: {
    updateAll: {
      get() {
        return this.allTotalChecked === this.allTotal && this.allTotal!=0;
      },
      set(val) {
       this.isAllChecked(val)
      },
    },
  },
};
</script>

<style>
/*footer*/
.todo-footer {
  height: 40px;
  line-height: 40px;
  padding-left: 6px;
  margin-top: 5px;
}

.todo-footer label {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}

.todo-footer label input {
  position: relative;
  top: -1px;
  vertical-align: middle;
  margin-right: 5px;
}

.todo-footer button {
  float: right;
  margin-top: 5px;
}
</style>